home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The X-Philes (2nd Revision)
/
The X-Philes Number 1 (1995).iso
/
xphiles
/
coding
/
dsp
/
bfltlib.exe
/
BCOS.C
< prev
next >
Wrap
Text File
|
1991-07-30
|
1KB
|
53 lines
/**************************************************************
bcos.c
staff
07-30-91
(C) Texas Instruments Inc., 1992
Refer to the file 'license.txt' included with this
this package for usage and license information.
*************************************************************/
#include "bflt.h"
bfloat bcos(bfloat in)
{
bfloat test;
long sign;
if(in.mantissa<0) in.mantissa = -in.mantissa;
test = bfix(bdiv(in,b_pi));
sign = b_long(test) & 0x1; /* 0==quad 1|2, 1==quad 3|4 */
in = bsub(in,bmpy(test,b_pi));
in = bsub(in,b_pi_two);
if(in.mantissa < 0)
{
in.mantissa = -in.mantissa;
if(sign==0)
sign = 1;
else
sign = -1;
}
else
{
if(sign==0)
sign = -1;
else
sign = 1;
}
in = bsub(b_pi_two,in);
if(bcomp(in,b_pi_four)<0)
in = bcosx(in);
else
{
in = bsub(b_pi_two,in);
in = bmpy(in,bsinx(in));
}
if(sign<0)
in.mantissa = -in.mantissa;
return(in);
}